package STUDENT.TRANNGUYENQUAN.OOPs.OBJECT_AND_CLASSES.Bai2;

import java.util.Scanner;

public class Views {
	public static void main(String[] args) {
		CalculatorControllers controller = new CalculatorControllers();
		Numbers num = new Numbers();
		Scanner sc;
		String numA= "";
		String numB= "";
		int iOpt;
		do {
			System.out.println("Nhap so a:");
			sc = new Scanner(System.in);
			String temp = sc.nextLine();
			if (!temp.isEmpty()) {
				numA = temp;
			} 
			else {
				System.out.println("Ban chua nhap a!");
				}
		} while (numA.isEmpty());

		do {
			System.out.println("Nhap so b:");
			sc = new Scanner(System.in);
			String temp = sc.nextLine();
			if (!temp.isEmpty()) {
				numB = temp;
			} 
			else {
				System.out.println("Ban chua nhap b!");
				}
		} while (numB.isEmpty());
		do {
			System.out.println("Nhap toan tu:");
			sc = new Scanner(System.in);
			int temp = sc.nextInt();
			if (temp >= 0 && temp <= 3) {
				iOpt = temp;
			} else {
				System.out.println("Ban chua nhap!");
				return;
			}
		} while (!(iOpt >= 0 && iOpt <= 3));
		num.setA(Double.parseDouble(numA));
		num.setB(Double.parseDouble(numB));
		num.setiOpt(iOpt);
		if (num.getB() == 0) {
			if (num.getA() == 0) {
				System.out.println("Result of function is underfined");
			} else {
				System.out.println("Cannot divide by zero ");
			}
		} else {
			controller.CalculatorInfo(num, iOpt);
		}
	}
}
